package com.cskaoyan.javase.oop3._1interface._3exercise;

/**
 * 1. 教练（Coach）和运动员（Sportsman）案例
 * > 小试牛刀请用所学知识分析：这个案例中有哪些抽象类，哪些接口，哪些具体类。
 * 现在有乒乓球运动员和篮球运动员，乒乓球教练和篮球教练。为了能够出国交流，跟乒乓球相关的人员都需要学习英语。
 *
 * 实际类: 乒乓球运动员和篮球运动员，乒乓球教练和篮球教练
 * 抽象类: 抽象的运动员类,抽象的教练类
 * 接口: 学习英语
 *
 * @since 14:55
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo {
    public static void main(String[] args) {
        AbstractSportsman as = new TableTennisSportsman();
        as.exercise();
        ((TableTennisSportsman) as).studyEnglish(17800);

        ILearning i =  new TableTennisSportsman();
        i.studyEnglish(10000);
        if (i instanceof TableTennisSportsman){
            // Cast may be removed by changing the type of 'i' to 'TableTennisSportsman'
            ((TableTennisSportsman) i).exercise();
        }

        TableTennisSportsman tts = new TableTennisSportsman();
    }
}

// 抽象的教练类
abstract class AbstractCoach {
    String name;
    int age;
    double salary;
    String course;

    public abstract void work();

}

// 抽象的教练类
abstract class AbstractSportsman {
    String name;
    int age;
    double salary;
    String sports;

    public abstract void exercise();
}

interface ILearning {
    void studyEnglish(double money);
}

class TableTennisSportsman extends AbstractSportsman implements ILearning {

    @Override
    public void exercise() {
        System.out.println("我打乒乓球,天下第一");
    }

    @Override
    public void studyEnglish(double money) {
        System.out.println("学英语，花了我" + money + "大洋！");
    }
}

class BasketballCoach extends AbstractCoach {

    @Override
    public void work() {
        System.out.println("我上课，教你打篮球！");
    }
}